package org.opens.javaskill.jvm.classloader.encryption;

import org.junit.Test;

import java.io.FileInputStream;
import java.io.FileOutputStream;

/**
 * @Date 2020/10/30 21:00
 * @Created by 99126
 */
public abstract class EncryptUtil {

    // 加密因子
    public static final byte ENCRYPT_FACTOR = (byte) 0x0f;

    public static void doEncrypt(String source, String target) {
        try (
                FileInputStream fis = new FileInputStream(source);
                FileOutputStream fos = new FileOutputStream(target);
        ) {
            int data;
            while ((data = fis.read()) != -1) {
                fos.write(data ^ ENCRYPT_FACTOR);
            }
            fos.flush();
        } catch (Exception e) {

        }
    }

    public static void main(String[] args) {
        doEncrypt("E:\\classloader\\classloader1\\org\\opens\\javaskill\\jvm\\classloader\\MyLoadObject.class", "E:\\classloader\\classloader2\\org\\opens\\javaskill\\jvm\\classloader\\MyLoadObject.class");
    }

    /**
     * 功能:
     * <p></p>
     * 输出:
     * <pre>
     *
     * </pre>
     * 说明:
     * <pre>
     *      1.
     * </pre>
     */
    @Test
    public void test46() {
        doEncrypt("E:\\classloader\\classloader1\\org\\opens\\javaskill\\jvm\\classloader\\MyLoadObject.class", "E:\\classloader\\classloader2\\org\\opens\\javaskill\\jvm\\classloader\\MyLoadObject.class");
    }

}
